package com.stone.business.cllyjl.service;

import java.util.List;

import com.stone.business.cllyjl.pojo.TClkcmx;
import com.stone.business.cllyjl.pojo.TCllyjl;
import com.stone.business.workcard.pojo.Gxzlkzk;
import com.stone.business.workcard.pojo.Gxzlkzk_BZ;
import com.stone.business.workcard.pojo.MainWorkCardOne;
import com.stone.business.workcard.pojo.Ryzzfg;
import com.stone.business.workcard.pojo.WorkCardOne_BZ;
import com.stone.business.workcard.pojo.Wxdfx;
import com.stone.common.pojo.TFile;

import frm.ssh.exception.AppException;
import frm.ssh.service.BaseService;

public class CllyjlService extends BaseService{

	
	/**
	 * 更新
	 * @param set 要改变的值
	 * @param ids 条件
	 * @param objectSimpleName
	 */
	public void update(final String set,final String ids,final String objectSimpleName){		
		super.updateByDHql(set, ids, null, null, objectSimpleName);
	}
	/**
	 * 删除多条记录
	 * 
	 * @param ids主键组合 以','号隔开
	 * @param objectSimpleName pojo
	 * @throws AppException
	 */
	public void doDelAll(final String ids,final String objectSimpleName) {
		super.deleteAll(ids, objectSimpleName);
	}
	/**
	 * 删除多条记录
	 * 
	 * @param ids主键组合 以','号隔开
	 * @param objectSimpleName pojo
	 * @throws AppException
	 */
	public void doDelAllBYDHSql(final String ids,final String objectSimpleName) {
		super.deleteAll(ids, objectSimpleName);
		super.deleteByDHql(" p_idsno in ("+ids+")", null, objectSimpleName);
	}	
	
	/**
	 * 保存材料领用记录，主副表
	 * @param entity 
	 * @param list
	 * @return
	 */
	public String doSave(TCllyjl entity, List<TClkcmx> list) {

		String strbz = "";
		
		if (entity.getId() == 0) {			
			super.save(entity);			
			if(list!=null)
			for (TClkcmx bz : list) {		
				if(bz!=null){
				bz.setParentid(entity.getId());
				bz.setDantype(entity.getDantype());
				super.save(bz);
				}
			}			
			
		}else{
				super.update(entity);
				
				if(list!=null){
					super.deleteByDHql(" parentid='"+entity.getId()+"' ", null, TClkcmx.class.getName());
					
				for (TClkcmx bz : list) {		
					if(bz!=null){
					bz.setParentid(entity.getId());
					bz.setDantype(entity.getDantype());
					super.save(bz);
					}
				}		
				}	
			
		}
		return "保存成功。";
		}	
	

	
	
}
